const files = require.context('../views', true, /\.vue$/)
const route = []

function hump(foo) {
  var arr = foo.split('/')
  for (var i = 1; i < arr.length; i++) {
    arr[i] = arr[i].charAt(0).toUpperCase() + arr[i].substring(1)
  }
  return arr.join('')
}

files.keys().forEach((key) => {
  const component = files(key).default
  if (component.name !== 'login') {
    const views = {}
    views.component = component
    views.path = key.replace(/.vue|\./g, '')
    views.name = hump(views.path)
    if (component.title) {
      views.meta = {
        title: component.title
      }
    }
    route.push(views)
  }
})

export default route
